package com.tonyodev.fetch2core;

/**
 * The reasons why onChanged method was called for a FetchObserver.
 *
 * @since 2021-05-20
 */
public enum Reason {
    /**
     * The reason was not specified.
     */
    NOT_SPECIFIED(0),

    /**
     * The download was added to Fetch database
     */
    DOWNLOAD_ADDED(1),

    /**
     * The download was queued for download.
     */
    DOWNLOAD_QUEUED(2),

    /**
     * The download is has started.
     */
    DOWNLOAD_STARTED(3),

    /**
     * The download is waiting on network to resume downloading.
     */
    DOWNLOAD_WAITING_ON_NETWORK(4),

    /**
     * The download progress has changed.
     */
    DOWNLOAD_PROGRESS_CHANGED(5),

    /**
     * The download has completed.
     */
    DOWNLOAD_COMPLETED(6),

    /**
     * An error occurred during download. See the download.getError() method.
     */
    DOWNLOAD_ERROR(7),

    /**
     * The download has been paused.
     */
    DOWNLOAD_PAUSED(8),

    /**
     * The download has been resumed.
     */
    DOWNLOAD_RESUMED(9),

    /**
     * The download has been cancelled.
     */
    DOWNLOAD_CANCELLED(10),

    /**
     * The download has been removed.
     */
    DOWNLOAD_REMOVED(11),

    /**
     * The download has been deleted.
     */
    DOWNLOAD_DELETED(12),

    /**
     * The download block has been updated. This is not used by FetchObservers
     * because the download blocks are updated on background threads very frequently
     * and will bog down the UI thread. FetchObservers are only called on the UI thread.
     * If you need to listen for this event. Use the FetchListeners instead.
     */
    DOWNLOAD_BLOCK_UPDATED(13),

    /**
     * When the FetchObserver is attached for the first time.
     */
    OBSERVER_ATTACHED(14),

    /**
     * A normal reporting of a FetchObserver. Used to report updates. etc.
     */
    REPORTING(15);

    private int value;

    /**
     * 构造函数
     *
     * @param value 值
     */
    Reason(int value) {
        this.value = value;
    }

    public int getValue() {
        return this.value;
    }
}
